# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=smstools
pkgver=3.1.21
pkgrel=1
_realname="${pkgname}${pkgver%\.[0-9]*\.[0-9]*}"
pkgdesc="SMS Gateway software which can send and receive short messages through GSM modems and mobile phones"
url="http://smstools3.kekekasvi.com/"
arch="all"
license="GPL"
makedepends="$depends_dev"
install=$pkgname.pre-install
options="!check"
pkgusers="smsd"
pkggroups="smsd"
source="http://smstools3.kekekasvi.com/packages/${_realname}-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.conf
	$pkgname.logrotate"
builddir="$srcdir"/$_realname

build() {
	cd "$builddir"
	make || return 1
}

package() {
	cd "$builddir"
	mkdir -p $pkgdir/usr/bin/ $pkgdir/usr/sbin/ || return 1
	install -m0755 $builddir/src/smsd $pkgdir/usr/sbin/smsd || return 1
	install -m0755 $builddir/scripts/sendsms $pkgdir/usr/bin/sendsms || return 1
	install -m0755 $builddir/scripts/sms2html $pkgdir/usr/bin/sms2html || return 1
	install -m0755 $builddir/scripts/sms2unicode $pkgdir/usr/bin/sms2unicode || return 1
	install -m0755 $builddir/scripts/unicode2sms $pkgdir/usr/bin/unicode2sms || return 1

	mkdir -p $pkgdir/etc/ || return 1
	install -m0644 $srcdir/smstools.conf $pkgdir/etc/smsd.conf || return 1

	mkdir -p $pkgdir/etc/init.d/ || return 1
	install -m0755 $srcdir/smstools.initd $pkgdir/etc/init.d/smsd || return 1

        #mkdir -p $pkgdir/etc/conf.d/ || return 1
	#install -m0644 $srcdir/smsd.confd $pkgdir/etc/conf.d/smsd || return 1

	mkdir -p $pkgdir/etc/logrotate.d/ || return 1
	install -m0644 $srcdir/smstools.logrotate $pkgdir/etc/logrotate.d/smsd || return 1

	#mkdir -p $pkgdir/usr/lib/tmpfiles.d/ || return 1
	#install -m0644 $srcdir/smsd.tmpfiles $pkgdir/usr/lib/tmpfiles.d/smsd.conf || return 1

	mkdir -p $pkgdir/var/spool/sms/incoming || return 1
	mkdir -p $pkgdir/var/spool/sms/outgoing || return 1
	mkdir -p $pkgdir/var/spool/sms/checked || return 1
	chmod 0750 $pkgdir/var/spool/sms || return 1
	chmod 0770 $pkgdir/var/spool/sms/* || return 1
	chown -R smsd:smsd $pkgdir/var/spool/sms || return 1

	mkdir -p $pkgdir/var/log/smsd || return 1
	chmod 0770 $pkgdir/var/log/smsd || return 1
	chown -R smsd:smsd $pkgdir/var/log/smsd || return 1
}

sha512sums="0587e5020a0318351ca99b68baa1c19411824279055857a5b5aa4e346cae373fe94a811eaca6767bcf991cf849eaaa66ec120f046420531a6088cdde9373db31  smstools3-3.1.21.tar.gz
31756bb80fb5b8ac8d1b8e29dae8926379ae2102e8931c06eb6713680e3a4d9ef5845b158e71cfe3e5d013b542341f8ec00acd1940f477d75c0fcd7d1c3e151a  smstools.initd
cf2a6d605f49df10d172bc412983312d37b315e42bdb82b2ce27eda4aaaec8526a6548db293457f48aa70b8d911a4169c77682f68850bef4c084b27ca478db9d  smstools.conf
668eed2143c1f08fe1deb27a20496317c77160f3278d68fbc54ac8008c5d266c0a2dc39551fd1ced92706bfffc0bc5ee7581e452670e3bff92837e598b98b10e  smstools.logrotate"
